package com.google.code.irouter.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public final class DateTimeUtil {

	public static int getDateInterval(Date date1, Date date2) {
		Long date1Long = date1.getTime();
		Long date2Long = date2.getTime();
		return Math.abs(Math.round((date1Long - date2Long)));
	}
	
	public static Date getNow(){
		return new Date();
	}
	
	public static String formatDate(Date date) {
		String result = "";
		if(date != null)
			if(Date.class.isInstance(date)) {
				SimpleDateFormat smf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				result = smf.format(date);
			}
		return result;
	}

}
